package com.wanmait.mavendemo.util;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5Utils
{
    public static String md5(String pass)
    {
        try {
            MessageDigest md = MessageDigest.getInstance("md5");
            byte b[] = md.digest(pass.getBytes());
            String passMd5 = new BigInteger(1,b).toString(16);
            for (int i = passMd5.length(); i < 32; i++)
            {
                passMd5 = "0"+passMd5;
            }
            return passMd5;
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return null;
    }

    public static String mymd5(String str,String salt)
    {
        return MD5Utils.md5(MD5Utils.md5(str+salt));
    }

    public static void main(String[] args) {
        System.out.println(MD5Utils.md5(MD5Utils.md5("123QATrWM")));
        System.out.println(MD5Utils.mymd5("123","QATrWM"));
    }
}











